package com.cu.current;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchDemo {

    public static void main(String[] args) {

        CountDownLatch countDownLatch = new CountDownLatch(2);

        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("thread1 start");
                countDownLatch.countDown();
                System.out.println("thread1 start1");
            }
        });



        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("thread2 start");
                countDownLatch.countDown();
                System.out.println("thread2 start1");
            }
        });

        thread1.start();
        thread2.start();
        try {
            countDownLatch.await();
            System.out.println("main start");
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
